package com.lijin.study.java.acct;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;

public class AccountParser {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("test")));
		
		String mcd = "";
		Set<String> s = new HashSet<String>();
		while (br.ready()) {
			mcd = br.readLine().trim().split("\\|")[0];
			if (s.contains(mcd)) {
				System.out.println(mcd);
			} else {
				s.add(mcd.trim());
			}
		}
		
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("D:\\test_result"))));
		for (String str : s) {
			bw.write(str + "\n");
		}
		bw.close();
	}
}
